/**
 * This file is part of gapro library.
 * 
 * gapro library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General
 * Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any
 * later version.
 * 
 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
 * details.
 * 
 * You should have received a copy of the GNU Lesser General Public License along with this program. If not, see
 * <http://www.gnu.org/licenses/>
 * 
 * Copyright 2012 Vinay Penmatsa. All rights reserved.
 */
package org.stupidwhiz.gapro.core;

/**
 * Utility class
 * 
 * @author Vinay Penmatsa
 * @since 1.0
 */
public class Util {

    /**
     * Return the greatest common divider of m and n
     * 
     * @param m
     * @param n
     * @return gcd of m and n
     */
    public static int gcd(int m, int n) {
        if(n == 0) {
            return m;
        }
        return gcd(n, m % n);
    }

    /**
     * Returns the least common multiple of m and n
     * 
     * @param m
     * @param n
     * @return lcm of m and n
     */
    public static int lcm(int m, int n) {
        return n * m / gcd(m, n);
    }

    /**
     * Tests if a string has a value. Spaces are value.
     * 
     * @param s
     * @return if the string contains a value
     */
    public static boolean hasValue(String s) {
        return s != null && s.length() != 0;
    }
}
